package com.example.bookkeeping;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView rv_his;
    HistoryAdaptar historyAdaptar;
    List<HistoryBean> historyBeanList;
    List<String> contentBeans;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rv_his = findViewById(R.id.rv_his);
        initData();

        rv_his.setAdapter(historyAdaptar);
        rv_his.setLayoutManager(new LinearLayoutManager(this));
        
    }

    private void initData() {
        historyBeanList = new ArrayList<>();
        contentBeans = new ArrayList<>();
        for (int i = 0; i < 8; i++) {
            contentBeans.add("我消费了---"+i+"元");
        }
        HistoryBean historyBean = new HistoryBean("2020-12-12",contentBeans);
        HistoryBean historyBean1 = new HistoryBean("2020-12-22",contentBeans);
        historyBeanList.add(historyBean);
        historyBeanList.add(historyBean1);
        historyAdaptar = new HistoryAdaptar(historyBeanList,this);
    }
}